package org.jmc.refmanager.web.wicket.page.navigation;

import org.apache.wicket.MarkupContainer;
import org.apache.wicket.PageParameters;
import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.basic.Label;
import org.jmc.refmanager.web.wicket.model.ServiceModel;
import org.jmc.refmanager.web.wicket.page.panel.ServiceViewPanel;
import org.jmc.refmanager.web.wicket.page.template.TemplatePage;

/**
 */
@AuthorizeInstantiation(value={"ROLE_MODIF", "ROLE_APPROVER"})
public class NavigationPage extends TemplatePage {

	/**
	 * @param parameters
	 */
	public NavigationPage(PageParameters parameters) {
		super(parameters);
		initComponents(parameters);
	}

	private void initComponents(PageParameters parameters) {
		add(new Label("pageTitle", "Navigation arborescente"));

		final Integer serviceId;
		
		if (parameters != null) {
			serviceId = parameters.getAsInteger("id", 0);
		} else {
			serviceId = 0;
		}
		
		ServiceViewPanel servicePanel = new ServiceViewPanel("viewServicePanel", new ServiceModel(serviceId), this.getClass());
		servicePanel.setVisible(serviceId != 0);
		servicePanel.setOutputMarkupId(true);
		add(servicePanel);

		add(new MarkupContainer("treeview") {
			private static final long serialVersionUID = 1L;
		});
	}
}

